/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import ts from '~/vendor/ohos-typescript';

import { NodePredicate } from '~/type/Predicate';

/**
 * @category AST Type
 */
export const BooleanLiteral: NodePredicate<ts.BooleanLiteral> = {
    is(node: ts.Node): node is ts.BooleanLiteral {
        return node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword;
    },
};

/**
 * @category AST Type
 */
export const NullLiteral: NodePredicate<ts.NullLiteral> = {
    is(node: ts.Node): node is ts.NullLiteral {
        return node.kind === ts.SyntaxKind.NullKeyword;
    },
};

/**
 * @category AST Type
 */
export const NumericLiteral: NodePredicate<ts.NumericLiteral> = {
    is(node: ts.Node): node is ts.NumericLiteral {
        return ts.isNumericLiteral(node);
    },
};

/**
 * @category AST Type
 */
export const BigIntLiteral: NodePredicate<ts.BigIntLiteral> = {
    is(node: ts.Node): node is ts.BigIntLiteral {
        return ts.isBigIntLiteral(node);
    },
};

/**
 * @category AST Type
 */
export const StringLiteral: NodePredicate<ts.StringLiteral> = {
    is(node: ts.Node): node is ts.StringLiteral {
        return ts.isStringLiteral(node);
    },
};

/**
 * @category AST Type
 */
export const RegularExpressionLiteral: NodePredicate<ts.RegularExpressionLiteral> = {
    is(node: ts.Node): node is ts.RegularExpressionLiteral {
        return ts.isRegularExpressionLiteral(node);
    },
};

/**
 * @category AST Type
 */
export const EndOfFileToken: NodePredicate<ts.EndOfFileToken> = {
    is(node): node is ts.EndOfFileToken {
        return node.kind === ts.SyntaxKind.EndOfFileToken;
    },
};
